<?php

class Twis_Template_Node_Call extends Twig_Node
{
    protected $method;
    protected $params;
    protected $varname;

    public function __construct($method, $params, $varname, $lineno, $tag)
    {
        parent::__construct($lineno);
        $this->method = $method;
        $this->params = $params;
        $this->varname = $varname;
    }

    public function compile($compiler)
    {
        $compiler
            ->addDebugInfo($this)
            ->write('$context[\''.$this->varname.'\'] = $this->env->getContext(\'proxy\')->call(')
            ->string($this->method);

        if (null !== $this->params) {
            $compiler->raw(", ")->subcompile($this->params);
        }

        $compiler->raw(");\n")
        ;
    }
}
